<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>函数作为数据使用</title>
    <script>
        function add(x){
            return x + 10;
        }
        console.log(add(8));   //18
        var otherAdd = add;   //把add赋值为变量otherAdd
        console.log(otherAdd(89));  //99

        //相当于
        var a = 1;
        var b = a;
        console.log(b);  //1


        var arr = [];
        arr[0] = function(x){
            return x + 10;
        }
        arr[1] = 9;
        console.log(arr[0](arr[1]));   //19

        //此处的小括号和！的作用都是把函数声明转换为函数表达式
        (function(){

        })();
        //或者
        !function(){

        }();

        var a = (1,2,3,alert);
        a(222);    //返回a中的最后一个元素，即alert,所以会在页面中弹出222

        var a = (1,2,3,4);
        console.log(a);   //4
    </script>
</head>
<body>

</body>
</html>